<ui:composition template="/WEB-INF/template.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

    <ui:define name="head">
        <title>Search for #{searchResultBean.keyword}</title>
        <f:metadata>
            <f:viewParam name="keyword" value="#{searchResultBean.keyword}" />
            <f:viewAction action="#{searchResultBean.doSearch()}" />
        </f:metadata>
    </ui:define>
    <ui:define name="content">
        <h1>Search results for #{searchResultBean.keyword}</h1>
        <p:dataScroller value="#{searchResultBean.searchResults}" var="result" chunkSize="20">
            <h:form>
                <h:panelGrid columns="4">
                    <p:link outcome="homeView" value="#{result.username}" >
                        <f:param name="username" value="#{result.username}" />
                    </p:link>
                    <p:outputLabel value="#{result.name}" />
                    <p:outputLabel value="#{result.surname}" />
                    <p:outputPanel rendered="#{invitationListBean.contains(result.username)}">
                        <p:link outcome="invitationList" title="Remove user from invitation list">
                            <f:param name="faces-redirect" value="true" />
                            <f:param name="usernameToRemove" value="#{result.username}" />
                            <p:graphicImage value="/resources/icons/mailminus32.png" height="30px" />
                        </p:link>
                    </p:outputPanel>
                    <p:outputPanel rendered="#{!invitationListBean.contains(result.username)}">
                        <p:link outcome="invitationList" title="Add user to invitation list">
                            <f:param name="faces-redirect" value="true" />
                            <f:param name="usernameToAdd" value="#{result.username}" />
                            <p:graphicImage value="/resources/icons/mailplus32.png" height="30px" />
                        </p:link>
                    </p:outputPanel>
                </h:panelGrid>
            </h:form>
        </p:dataScroller>
    </ui:define>
</ui:composition>